import request from "@/utils/request";

// 查询spu信息列表
export function listSpuInfo(query) {
  return request({
    url: "/product/spuInfo/list",
    method: "get",
    params: query,
  });
}

// 查询spu信息详细
export function getSpuInfo(spuId) {
  return request({
    url: "/product/spuInfo/" + spuId,
    method: "get",
  });
}

// 新增spu信息
export function addSpuInfo(data) {
  return request({
    url: "/product/spuInfo",
    method: "post",
    data: data,
  });
}

// 修改spu信息
export function updateSpuInfo(data) {
  return request({
    url: "/product/spuInfo",
    method: "put",
    data: data,
  });
}

// 删除spu信息
export function delSpuInfo(spuId) {
  return request({
    url: "/product/spuInfo/" + spuId,
    method: "delete",
  });
}

// 商品上架
export function releaseSpu(spuId) {
  return request({
    url: `/product/spuInfo/upPublish/${spuId}`,
    method: "put",
  });
}

// 商品下架
export function unReleaseSpu(spuId) {
  return request({
    url: `/product/spuInfo/downPublish/${spuId}`,
    method: "put",
  });
}

// 修改spu属性关联
export function updateSpu2Attr(data) {
  return request({
    url: `/product/attrValue/batch`,
    method: "put",
    data,
  });
}
